<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>siri</title>

	<!--新增-->
	<link rel="stylesheet" href="css/normalize.css">
	<link rel="stylesheet" href="css/demo.css">
	<link rel="stylesheet" href="dist/botui.min.css">
	<link rel="stylesheet" href="dist/botui-theme-default.css">


</head>
<body>

	<div class="htmleaf-content">
		<div class="botui-app-container" id="home-demo">
			  <bot-ui></bot-ui>
		</div>
	</div>


	<div class="botui-app-container" id="hello-world">
		<bot-ui></bot-ui>
	</div>



	<!--新增-->
	<script src="js/vue.min.js"></script>
	<script src="dist/botui.js"></script>

	<script type="text/javascript">
		var homeBot = BotUI('home-demo');

		homeBot.message.add({
		  content: '您好！'
		}).then(function () {
		  return homeBot.message.add({
		    delay: 1500,
		    content: '需要小robot为您提供服务吗?'
		  });
		}).then(function () {
		  return homeBot.action.button({
		    delay: 1000,
		    action: [{
		      text: '好的!',
		      value: 'sure'
		    }, {
		      text: '不用了😒,回到初始界面',
		      value: 'skip'
		    }]
		  });
		}).then(function (res) {
		  if(res.value == 'sure') {
		    tutorial();
		  }
		  if(res.value == 'skip') {
		    end();
		  }
		});




		var tutorial = function () {
		  homeBot.message.add({
		    delay: 1000,
		    content: "robot很高兴为您服务"
		  }).then(function () {
		    return homeBot.message.add({
		      delay: 1000,
		      content: '你可以提出一些简单的问题，例如：'
		    });
		  }).then(function () {
		    return homeBot.message.add({
		      delay: 1200,
		      content: '你叫什么名字?'
		    });
		  }).then(function () {
		    return homeBot.action.text({
		      delay: 800,
		      action: {
		        value: 'bunny',
		        placeholder: '填写你的名字'
		      }
		    });
		  }).then(function (res) {
		    return homeBot.message.bot({
		      delay: 500,
		      content: res.value + ' 是个好名字！'
		    });
		  }).then(function () {
                  return homeBot.message.add({
                      delay: 1000,
                      content: '需要小robot为您提供当季最适合旅游的地点吗?'
                  });
              }).then(function () {
              return homeBot.action.button({
                  delay: 1000,
                  action: [{
                      text: '好的!',
                      value: 'sure'
                  }, {
                      text: '不用了😒,回到初始界面',
                      value: 'skip'
                  }]
              });
          }).then(function (res1) {
                  if(res1.value == 'sure') {
                      travel();
                  }
                  if(res1.value == 'skip') {
                      end();
                  }
              });

			var travel = function (){
                homeBot.message.add({
                    delay: 1000,
                    content: "通过大数据可计算出,当前最适合去的景区为"
                }).then(function () {
                    return homeBot.message.add({
                        delay:1000,
                        content:'广州'
                    })
                }).then(function () {
                    return homeBot.message.add({
                        type: 'embed',
                        content: 'http://img.redocn.com/sheying/20151127/guangzhouxiaoxiangdao_5408310_small.jpg'
                    })
                }).then(function () {
                    return homeBot.message.add({
                        delay:1200,
                        content:"北京"
                    })
                }).then(function () {
                    return homeBot.message.add({
                        type:'embed',
                        content:'http://userimg.qunarzz.com/imgs/201012/24/kkQG8NWskmdRtGk720.jpg'
                    })
                }).then(function () {
                    return homeBot.message.add({
                        delay: 1000,
                        content: '还需要小roots为您再次推荐景点吗?'
                    });
                }).then(function () {
                    return homeBot.action.button({
                        delay: 1000,
                        action: [{
                            text: '好的!',
                            value: 'sure'
                        }, {
                            text: '不用了😒,回到初始界面',
                            value: 'skip'
                        }]
                    });
                }).then(function (res1) {
                    if(res1.value == 'sure') {
                        travel();
                    }
                    if(res1.value == 'skip') {
                        homeBot.message.add( {
                            delay:800,
                            content:'好的本次服务到此结束'
                        })
                        end();
                    }
                }).then(function (res) {
                    return homeBot.message.bot({
                        delay: 2500,
                        content: '好的本次服务到此结束'
                    });
                }).then(function (res) {
                    return homeBot.message.bot({
                        delay: 1000,
                        content: '下面返回我的界面'
                    });
                }).then(end);
            }}


		var end = function () {
		  /*homeBot.message.add({
		    delay: 1000,
		    content: '!(book) [Read the docs](https:///docs.botui.org), see [examples](https:///examples.botui.org) or explore the code on !(github) [GitHub](https://github.com/moinism/botui)'
		    content:'http://localhost/index.html'
		  });*/
		  setTimeout(function () {

		  location.href="http://localhost/index.html"
          },2500)
		};








	</script>
</body>
</html>